<?php
include ("../cgi-bin/global.inc.php");
include ("fonctions.php");

	$sql = "SELECT id from missions ";
	$rsql = mysql_query($sql) or die("Imprimer cette page : <br>erreur sql = ".$sql);
	while($table_liste = mysql_fetch_object($rsql))	{
			$sql = "SELECT id from tache WHERE activite=$table_liste->id AND type='M' ";
	    		$rsql2 = mysql_query($sql) or die("Imprimer cette page : <br>erreur sql = ".$sql);
			if (mysql_num_rows($rsql2)==0)
				{
				$sql = "SELECT valeur from referentiel WHERE code='tache' ";
	    			$rsql3 = mysql_query($sql) or die("Imprimer cette page : <br>erreur sql = ".$sql);
      				while($table_liste3 = mysql_fetch_object($rsql3))	{
					$sql = "insert INTO tache(libelle,valide,activite,type,maj) VALUES('".$table_liste3->valeur."',1,'".$table_liste->id."','M','".$date."')"; 
					$resultat = mysql_query($sql) or die("Imprimer cette page : <br>erreur sql = ".$sql);
					}
				}
		}
?>
